<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>

<script>
    function myTime(fn,a,b){
        let count = 1;
        let timerId;
        function sd(){
            let delay = a + (count-1)*b
            timerId=  setTimeout(()=>{
                fn()
                count ++
                sd()
                console.log(count,delay)
            },delay)
        }
        sd()
        return function (){
            clearTimeout(timerId)
        }
    }
    function callBack(){
        // console.log('nn')
    }
   let cb =  myTime(callBack,1000,2000)
    console.log(cb)



    // const Foo = (function(){
    //     let count = 0;
    //     function Foo(){
    //         console.log(this)
    //         if(!(this instanceof Foo)){
    //             return new Foo()
    //         }
    //         count++
    //         this.id = count
    //     }
    //     return Foo
    // })()
    // console.log(Foo)
    // let a = new Foo()
    // console.log(a)
    //
    // function ww(name){
    //     this.name = name
    //     console.log(this)
    // }
    // ww('22')
    // let w = new ww('1')
    // console.log(w)
</script>
</body>
</html>
